package com.cloud.demo2020.config;

import com.cloud.demo2020.common.ResultBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Configuration
@RestControllerAdvice
public class RestAdviceConfig {

    @ExceptionHandler(Exception.class)
    @ResponseStatus(code = HttpStatus.SERVICE_UNAVAILABLE)
    public ResultBean exception(Exception e) {
        return new ResultBean(false, "未知错误.");
    }
}
